package com.learning.spring.ioc.bean.xml.factory;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * ClassName: MainTest
 * Description:
 * Date: 2018/8/5 11:19 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
public class MainTest {
    public static void main(String[] args) throws Exception {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-context.xml");

        // 获取 CustomBean 的 bean 对象
        CustomBean customBean = context.getBean("customFactoryBean", CustomBean.class);
        customBean.done();

        // 获取 FactoryBean 实例 ，需要加上 &
        CustomFactoryBean customFactoryBean = context.getBean("&customFactoryBean", CustomFactoryBean.class);
        customFactoryBean.getObject().done();

        ((ClassPathXmlApplicationContext) context).close();
    }
}
